package com.xiaocai.myblog.exception;

import com.xiaocai.myblog.enums.ErrorCodeEnum;

/**
 * @author chenhefu
 * @date 2019-09-30 18:08
 * 全局业务异常
 */
public class BusinessException extends RuntimeException {

    private ErrorCodeEnum errorCode;
    private String msg;
    public BusinessException(ErrorCodeEnum code, Throwable cause) {
        super(code.getMsg(), cause);
        this.errorCode = code;
    }
    public BusinessException(ErrorCodeEnum code, String cause) {
        super(cause);
        this.errorCode = code;
        this.msg = cause;
    }

    public BusinessException(ErrorCodeEnum code) {
        this.errorCode = code;
    }

    public ErrorCodeEnum getErrorCode() {
        return errorCode;
    }

    public void setErrorCode(ErrorCodeEnum errorCode) {
        this.errorCode = errorCode;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }
}
